<?php
/**
 * 发圈任务接取列表
 * author itholiday@126.com
 */
global $_W, $_GPC;
$html_title = $_W['current_module']['title'];

load()->func('tpl');
$op = !empty($_GPC['op']) ? $_GPC['op'] : 'list';
//页面显示条数
$pagesize = 15;
$page = max(1, $_GPC['page']);
$start = ($page - 1) * $pagesize;

$where = 'A.id>0 ';

$userinfo = isset($_GPC['userinfo']) && !empty($_GPC['userinfo']) ? input('userinfo') : '';
$start_time_2 = isset($_GPC['start_time_2']) && !empty($_GPC['start_time_2']) ? strtotime($_GPC['start_time_2']) : '';
$end_time_2 = isset($_GPC['end_time_2']) && !empty($_GPC['end_time_2']) ? strtotime($_GPC['end_time_2']) : '';
$review_status = isset($_GPC['review_status']) && $_GPC['review_status'] != '' ? $_GPC['review_status'] : '';
if (!empty($userinfo)) {
    $where .= " and (B.mobile like '%$userinfo%' or B.truename like '%$userinfo%') ";
}

if (!empty($start_time_2) && !empty($end_time_2)) {
    $where .= " and A.create_time>=$start_time_2 and A.create_time<=$end_time_2 ";
} else {
    if (!empty($start_time_2)) {
        $where .= " and A.create_time>=$start_time_2 ";
    }
    if (!empty($end_time_2)) {
        $where .= " and A.create_time<=$end_time_2 ";
    }
}
if ($review_status != '') {
    $where .= " and A.review_status=$review_status ";
}

if ($op == 'list' || $op == '') {

    $total = pdo_fetchcolumn('SELECT COUNT(*) AS `number` FROM ' . tablename('yq_haircircle_share_task_log') . ' A left join ims_yq_haircircle_users B on A.user_id=B.id WHERE ' . $where);

    //生成分页HTML
    $pager = getPageHTML($total, $page, $pagesize);
    $sql = "select A.*,B.mobile from ims_yq_haircircle_share_task_log A left join ims_yq_haircircle_users B on A.user_id=B.id where $where order by A.id desc limit $start,$pagesize";
    $list = pdo_fetchall($sql);
    $list = $list ? $list : array();
    if ($list) {
        foreach ($list as $k => $v) {
            if (!empty($v['submit_img'])) {
                $thumbs = explode(';', trim($v['submit_img'], ';'));
                foreach ($thumbs as $kk => $vv) {
                    $thumbs[$kk] = cmf_get_upload_url($vv);
                }
                $list[$k]['submit_img'] = implode(';', $thumbs);
            } else {
                $list[$k]['submit_img'] = '';
            }

        }
    }
    include $this->template('web/share_task_log_list');
    exit;
}